<?php

namespace App\Http\Controllers\Api;

use App\Services\SampleService;
use Illuminate\Http\Request;


class IndexController extends BaseController
{



    /**
     * @OA\Get(
     *     path="/api/index/index",
     *     @OA\Response(
     *         response="200",
     *         description="The data"
     *     )
     * )
     */
    public function index(Request $request)
    {
        $res = [
            'code' => '200',
            'data' => [
                'LastFiveYearsPopulationGrowthRate' => [
                    ['time' => '2023', 'value' => '10'],
                    ['time' => '2022', 'value' => '8'],
                    ['time' => '2021', 'value' => '9'],
                    ['time' => '2020', 'value' => '6'],
                    ['time' => '2019', 'value' => '2'],
                    ['time' => '2018', 'value' => '4'],
                    ['time' => '2017', 'value' => '1'],
                ],
                'SquadronCaseCount' => [
                    ['name' => '第一中队', 'value' => '594'],
                    ['name' => '第二中队', 'value' => '494'],
                    ['name' => '第三中队', 'value' => '162'],
                    ['name' => '综合执法科', 'value' => '99'],
                ],
                'ResidentPopulation' => [
                    'finish' => [
                        ['time' => '一月', 'value' => '67'],
                        ['time' => '二月', 'value' => '76'],
                        ['time' => '三月', 'value' => '51'],
                        ['time' => '四月', 'value' => '36'],
                        ['time' => '五月', 'value' => '68'],
                    ],
                    'underway' => [
                        ['time' => '一月', 'value' => '45'],
                        ['time' => '二月', 'value' => '87'],
                        ['time' => '三月', 'value' => '23'],
                        ['time' => '四月', 'value' => '34'],
                        ['time' => '五月', 'value' => '34'],
                    ]
                ],
                'NumberOfBirthsAndDeaths' => [
                    'births' => [
                        ['time' => '一月', 'value' => '82'],
                        ['time' => '二月', 'value' => '93'],
                        ['time' => '三月', 'value' => '100'],
                        ['time' => '四月', 'value' => '203'],
                        ['time' => '五月', 'value' => '214'],
                        ['time' => '六月', 'value' => '108'],
                        ['time' => '七月', 'value' => '123'],
                    ],
                    'deaths' => [
                        ['time' => '一月', 'value' => '92'],
                        ['time' => '二月', 'value' => '34'],
                        ['time' => '三月', 'value' => '123'],
                        ['time' => '四月', 'value' => '92'],
                        ['time' => '五月', 'value' => '80'],
                        ['time' => '六月', 'value' => '20'],
                        ['time' => '七月', 'value' => '90'],
                    ]
                ],
                'SownArea' => [
                    ['name' => '玉米', 'value' => '233.8'],
                    ['name' => '马铃薯', 'value' => '92.7'],
                    ['name' => '水稻 ', 'value' => '53.2'],
                    ['name' => '大豆', 'value' => '322.9']
                ],
                'ScientificAndTechnologicalInnovation' => [
                    ['name' => '3户企业引进科技成果6项', 'value' => '40'],
                    ['name' => '省级科技型中小企业21户', 'value' => '38'],
                    ['name' => '新建科技创新平台3个 ', 'value' => '32'],
                    ['name' => '1个省级创新中心 ', 'value' => '30'],
                    ['name' => '国家级高新技术企业成功申报1户 ', 'value' => '28'],
                    ['name' => '全年生成转化科技成果21项 ', 'value' => '26'],
                    ['name' => '2个“头雁”团队工作站子站 ', 'value' => '22'],
                    ['name' => '新技术、新成果推广10项', 'value' => '18']
                ],
                'EventSource' => [
                    ['name' => '部门共享', 'value' => '80'],
                    ['name' => '群众上报', 'value' => '60'],
                    ['name' => '志愿者采集 ', 'value' => '78'],
                    ['name' => '智能预测 ', 'value' => '30'],
                    ['name' => 'AI识别 ', 'value' => '56'],
                    ['name' => '网格员侧击 ', 'value' => '94'],
                    ['name' => '警员上报', 'value' => '67']
                ]
            ],
            'message' => '数据获取成功',
            'success' => true
        ];
        return response()->json($res);
    }

    public function lastFiveYears(Request $request)
    {
        $res = [
            'code' => 200,
            'data' => [
                ['time' => '2023', 'value' => '10'],
                ['time' => '2022', 'value' => '8'],
                ['time' => '2021', 'value' => '9'],
                ['time' => '2020', 'value' => '6'],
                ['time' => '2019', 'value' => '2'],
            ],
            'message' => '数据获取成功',
            'success' => true
        ];
        return response()->json($res);
    }

    public function birthAndDeath(Request $request)
    {
        $res = [
            'code' => 200,
            'data' => [
                'births' => [
                    ['time' => '一月', 'value' => '82'],
                    ['time' => '二月', 'value' => '93'],
                    ['time' => '三月', 'value' => '100'],
                    ['time' => '四月', 'value' => '203'],
                    ['time' => '五月', 'value' => '214'],
                    ['time' => '六月', 'value' => '108'],
                    ['time' => '七月', 'value' => '123'],
                ],
                'deaths' => [
                    ['time' => '一月', 'value' => '92'],
                    ['time' => '二月', 'value' => '34'],
                    ['time' => '三月', 'value' => '123'],
                    ['time' => '四月', 'value' => '92'],
                    ['time' => '五月', 'value' => '80'],
                    ['time' => '六月', 'value' => '20'],
                    ['time' => '七月', 'value' => '90'],
                ]
            ],
            'message' => '数据获取成功',
            'success' => true
        ];
        return response()->json($res);
    }

    public function residentPopulation(Request $request)
    {
        $res = [
            'code' => 200,
            'data' => [
                ['name' => '道里', 'value' => '67'],
                ['name' => '道外', 'value' => '76'],
                ['name' => '南岗', 'value' => '51'],
                ['name' => '香坊', 'value' => '36'],
                ['name' => '松北', 'value' => '68'],
            ],
            'message' => '数据获取成功',
            'success' => true
        ];
        return response()->json($res);
    }

    public function eventSource(Request $request)
    {
        $res = [
            'code' => 200,
            'data' => [
                ['name' => '部门共享', 'value' => '82'],
                ['name' => '群众上报', 'value' => '61'],
                ['name' => '志愿者采集 ', 'value' => '78'],
                ['name' => '智能预测 ', 'value' => '72'],
                ['name' => 'AI识别 ', 'value' => '66'],
                ['name' => '网格员侧击 ', 'value' => '94'],
                ['name' => '警员上报', 'value' => '77']
            ],
            'message' => '数据获取成功',
            'success' => true
        ];
        return response()->json($res);
    }

    public function test(Request $request)
    {
        $rtn = (new SampleService())->run();
        print_r($rtn);
    }

}
